package com.tao.service;

import com.tao.mapper.PicMapper;
import com.tao.pojo.Pic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@CacheConfig(cacheNames = "PIC")
public class PicServiceImpl implements PicService {

    private static final String CACHE_KEY = "PIC";
    @Autowired
    PicMapper picMapper;

    @Override
    @CacheEvict(key = "9527")
    public int deleteByPrimaryKey(Integer id) {
        return picMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Pic selectByPrimaryKey(Integer id) {
        return picMapper.selectByPrimaryKey(id);
    }

    @Override
    @CacheEvict(key = "9527")

    public int updateByPrimaryKeySelective(Pic record) {
        return picMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    @CacheEvict(key = "9527")
    public int updateByPrimaryKey(Pic record) {
        return picMapper.updateByPrimaryKey(record);
    }

    @Override
    @Cacheable(cacheNames = "PIC",key="9527")
//    @CachePut(value = "Pic",key = "PicSelectAll")
    public List<Pic> selectAll() {
        return picMapper.selectAll();
    }

    @Override
    @CacheEvict(key = "9527")
    public int insertPic(Pic pic) {
        return picMapper.insertPic(pic);
    }
}
